1. Field of the Invention
The present invention relates to a variable length decoding apparatus and method for the image format of a digital video camera (DV). In particular, this invention provides an apparatus and method for decoding the images of a digital video camera on the PASS2 decoding layer.
2. Description of the Related Art
All video encoding standards, such as MPEG, WMV, DV etc., have the same syntax for the encoded bit stream, except DV. In MPEG format, the bit stream is continuous and the length for allocating the encoded bit stream of the macro block is not fixed; that depends on the length of the encoded bit stream. A macro block includes six blocks. However, in DV video format, the length for allocating the encoded bit stream of the macro block is fixed. The length is eighty bytes. In the DV video format, if we use 4:1:1 encoding format to encode a block, the luminance block only occupies fourteen bytes and the chrominance block only occupies ten bytes. The length of encoded bit stream of the block sometimes will exceed the size of the allocated block and sometimes the length of encoded bit stream of the block will be less than the size of the allocated block. When the size of the encoded bit stream of the block exceeds the size of the allocated block, the surplus part of the encoded bit stream will be saved in the neighboring block. Therefore, when decoding, there are three decoding layers for decoding the encoded bit stream of the image. The three decode layers are called PASS1 decoding layer, PASS2 decoding layer, and PASS3 decoding layer.
The PASS1 decoding layer is a basic decoding layer. The PASS1 decoding layer only decodes the data within the allocated block or at the end of a block (EOB). The coefficients of high frequency that are not decoded will be filled in as zero. The PASS2 decoding layer uses a macro block as a unit. If the size of the coefficient of the encoded image is over than that of the allocated block, the PASS2 decoding layer will decode the bit stream that are located in the neighboring block within the macro block. The method combines the residual bit stream of the allocated block with the bit streams allocated in the neighboring block and decodes them by looking up a table. The PASS2 decoding layer will decode the bit streams within the macro block. Other coefficients of high frequency that exceed the macro block will be filled in as zero. The PASS3 decoding layer operates in the same way as the PASS2 decoding layer; the only difference being that the PASS3 decoding layer uses a video segment as a decoding unit. A video segment has five macro blocks.
Please refer to FIG. 1, which shows the prior space allocations of the bit stream of the PASS1 decoding layer for a DV image format. A macro block 10 is composed of six blocks Y0, Y1, Y2, Y3, Cr and Cb. The blocks Y0, Y1, Y3 and Cb have end of blocks (EOB) 11, 12, 13 and 14. The blocks Y2 and Cr don't have an EOB.
Refer to FIG. 2, which shows the prior variable length decoder of the PASS1 decoding layer for DV image format. The apparatus comprises two registers 20 and 21 for saving the decoding bit stream, a barrel shifter 22 for outputting data produced by the bit stream and uses sixteen bits as a unit, an accumulator 24 for accumulating the bit number of the bit stream that is being decoded. The result of the accumulator will be sent to the barrel shifter 22, a programmable logic array 23 for decoding the image according to the output data of barrel shifter 22, a controller 26 for controlling the decoding process and the bit number of fixed length decode, and a multiplexer 25 for switching the input of the accumulator 24, the input of the multiplexer 25 includes the bit number which comes from the look-up table through the programmable logic array 23 and the bit number of fixed length decode from the controller 26.
The prior variable length decoder of the PASS1 decoding layer for DV image format will only decode the bit stream until the EOB of the block or the allocated address of the block. Other coefficients of high frequency components will be filled in as zero. Therefore, the prior art will lose the high frequency component and can't be applied to the PASS2 decoding layer.